﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Actya.Core.Content;
using Actya.Core.SiteStructure;

namespace Actya.Web.ViewModels.Admin
{
	public class EditPageViewModel
	{
		public string Id { get; set; }

		[Required]
		public string PageTitle { get; set; }

		[Required]
		public string LayoutId { get; set; }

		public string UrlPrefix { get; set; }
		public bool IncludeInNavigation { get; set; }
		public string ParentId { get; set; }
		public string Slug { get; set; }
		public string MenuText { get; set; }
        public string Url { get; set; }
		public bool IsHomePage { get; set; }
		public bool IsPublished { get; set; }
		public DateTime? PublicationDate { get; set; }
		public DateTime? OfflineDate { get; set; }

		public string ContentModelType { get; set; }
		public IContent Content { get; set; }

		public IEnumerable<PageLayout> AvailablePageLayouts { get; set; }
		
		public bool IsActive
		{
			get
			{
				return this.IsPublished
					&& (this.PublicationDate == null || this.PublicationDate <= DateTime.Now)
					&& (this.OfflineDate == null || this.OfflineDate > DateTime.Now);
			}
		}
	}
}